import {
  FormGroup
} from '@angular/forms';

export abstract class BaseComponent {

  abstract validateForm: FormGroup;

  valid(): boolean {
    const res = this.validateForm.valid;
    if (!res) {
      Object.keys(this.validateForm.controls).forEach((v) => {
        this.validateForm.controls[v].markAsDirty();
        this.validateForm.controls[v].updateValueAndValidity();
      });
    }
    return res;
  }

  get formValue(): any {
    return this.validateForm.value;
  }
}
